<template>
  <div v-if="visible" :key="visible" class="fullscreen-container">
    <!-- 弹窗内容区 -->
    <div class="fullscreen-content">
      <!-- 关闭按钮 -->
      <button class="fullscreen-close" @click="handleClose">×</button>
      <!-- 动态渲染对应统计内容 -->
      <div class="fullscreen-body">
        <!-- 根据弹窗类型显示不同组件 -->
        <component :is="componentName" :data="data"></component>
      </div>
    </div>
  </div>
</template>

<script>
import DispatcherStats from "@/views/stats/dispatcher/DispatcherStats/index.vue";
import DutyDispatcherStats from "@/views/stats/dispatcher/DutyDispatcherStats/index.vue";
import CarUnitStats from "@/views/stats/CarUnitStats/index.vue";
import CallStats from "@/views/stats/business/CallStats/index.vue";

export default {
  components: {
    DispatcherStats,
    DutyDispatcherStats,
    CarUnitStats,
    CallStats
  },
  data() {
    return {

    }
  },
  computed: {
    // 从 Vuex 获取弹窗状态
    visible() {
      return this.$store.state.popup.visible;
    },
    componentName() {
      return this.$store.state.popup.componentName;
    },
    data() {
      return this.$store.state.popup.data;
    }
  },
  methods: {
    // 关闭弹窗（调用 Vuex action）
    handleClose() {
      this.$store.dispatch('popup/closePopup');
    }
  }
};
</script>

<style scoped>

.fullscreen-content {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("@/assets/pageBg.png");
  background-size: cover;
  background-position: center center;
  z-index: 9999999; /* 内容区层级最高 */
  padding: 8px;
  box-sizing: border-box;
}

.fullscreen-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 22px;
  height: 22px;
  background: transparent;
  color: #3DE7C9;
  font-size: 22px;
  line-height: 22px;
  cursor: pointer;
  outline: none;
  border: 1px solid #3DE7C9;
}

.fullscreen-body {
  margin-top: 18px;
  color: #FFF;
}
</style>
